!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! calculate x4, y4 from given nozzle wall function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! wall function is y=aw+bw*x+cw*x^2
! slope of wall is dy/dx=tan(theta)=bw+2*cw*x
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! nomenclature:
!   aw,bw,cw    wall equation constant
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! warning:
!   all angle in rad, not degree
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine Wall24(lp)
   use VariableDef
   implicit none
   real*8::lp
   
   if (abs(thetae-thetaa) <= 0.01) then   ! line
      cw=0.0
      x4=(aw-y2+lp*x2)/(lp-bw)
      y4=aw+bw*x4+cw*x4**2
      theta4=atan(bw+2*cw*x4)
   else   ! curve
      x4=(lp-bw-sqrt((lp-bw)**2-4*cw*(aw-y2+lp*x2)))/(2*cw)
      y4=aw+bw*x4+cw*x4**2
      theta4=atan(bw+2*cw*x4)
   end if
   
end subroutine Wall24
